Added ProtocolHelper and some tests
[brmtron.git] / BrmTron Server / src / cz / brmlab / brmtron / server / test / ProtocolHelperTest.java
blobe29425074103c941d28f4a3f54219945631b6eaa
1 package cz.brmlab.brmtron.server.test;
3 import static org.junit.Assert.*;
5 import org.junit.Test;
7 import cz.brmlab.brmtron.server.Player;
8 import cz.brmlab.brmtron.server.ProtocolHelper;
10 public class ProtocolHelperTest {
12 @Test
13 public void test_parsePlayer(){
14 Player p;
15 String input = "1 --- tester --- 1.1123 --- 54.4234 --- true\n";
17 p = ProtocolHelper.parsePlayer(input);
19 assertTrue(p.getId() == 1);
20 assertTrue(p.getName().equals("tester"));
21 assertTrue(p.getLongitude() == 1.1123);
22 assertTrue(p.getLatitude() == 54.4234);
23 assertTrue(p.isActive());
26 @Test
27 public void test_buildPlayer() {
28 String inp = "1 --- tester --- 1.1123 --- 54.4234 --- true\n";
29 Player p = ProtocolHelper.parsePlayer(inp);
30 String s = ProtocolHelper.buildPlayer(p);
31 assertTrue(s.equals(inp));